package eirkdbd.lab1.gui;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import eirkdbd.lab1.gui.tab.AbstractTab;
import eirkdbd.lab1.gui.tab.BipolarQueryTab;
import eirkdbd.lab1.gui.tab.FunctionDefinitionTab;
import eirkdbd.lab1.gui.tab.MainConditionsTab;
import eirkdbd.lab1.gui.tab.SubConditionsTab;

public class TabbedPane extends JTabbedPane {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 9000L;
	 public static final Color TRANSPARENT = new Color(0, 0, 0, 0);

	public TabbedPane() {
		init();
	}
	
	private void init() {
		setTabPlacement(LEFT);
		setFont(new Font("Arial", Font.BOLD, 12));
		setForeground(Color.orange);
		setBackground(Color.darkGray);
		 
		setBorder(null);
		addTab(FunctionDefinitionTab.TITLE, new FunctionDefinitionTab());
		addTab(MainConditionsTab.TITLE, new MainConditionsTab());
		addTab(SubConditionsTab.TITLE, new SubConditionsTab());
		addTab(BipolarQueryTab.TITLE, new BipolarQueryTab());
		
		addChangeListener(new TabSwitchListener());
	}
	
	class TabSwitchListener implements ChangeListener {

		public void stateChanged(ChangeEvent ce) {
			if(getSelectedComponent() instanceof AbstractTab) {
				((AbstractTab) getSelectedComponent()).refreshUi();
			}
		}
		
	}
}